package com.chinanet.server;

import com.chinanet.config.WebSecurityConfig;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.reactive.server.WebTestClient;

/**
 * Create by Lourd on 2018/12/13
 *
 * SpringBootの機能を使う場合に必要なアノテーション
 * 注意:間違っている!
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureWebTestClient
//@DirtiesContext
@Import(WebSecurityConfig.class)
public class AllControllerTestWithMockWebTestClient {

    @Autowired
    private WebTestClient webClient;

    @Before
    public void setUp() throws Exception {
    }


    @After
    public void tearDown() throws Exception {
    }

    @Test
    public void exampleTest() {
        this.webClient.get().uri("/").exchange().expectStatus().isOk()
                .expectBody(String.class).isEqualTo("Hello World");
    }

    @Test
    public void createAuthenticationToken() {
    }

    @Test
    public void refreshAndGetAuthenticationToken() {
    }

    @Test
    public void getUserByAuthenticationToken() {
    }
}